<!-- design-info.vue -->
<template>
  <view>
	  <wd-collapse v-model="value" class="list">
	    <wd-collapse-item
	      v-for="_ in dictionaryStore.get('decoration_design_order_measure_class')"
	      :key="_.value"
	      :title="_.label"
	      :name="`measureInfo${_.value}`"
	    >
	      <template v-for="info in transformedData.filter((item) => item.fileType === 'measure' && item.fileSecondType === _.value)" :key="info.id">
	        <wd-divider>
	          {{ userStore.getUserNameById(info.creator) }} {{ dayjs(info.createTime).format('YYYY-MM-DD HH:mm:ss') }}
	        </wd-divider>
			<view class="file-container">
				<template v-for="(file, index) in info.fileUrl" :key="index">
          		  <file-preview :file="file" />
          		</template>
			</view>
	      </template>
	    </wd-collapse-item>
          <!-- 方案 -->
      	<wd-collapse-item
	     
	      key="plane"
	      title="方案"
	      name="plane"
	    >
	      <template v-for="info in transformedData.filter((item) => item.fileType === 'plane')" :key="info.id">
	        <wd-divider>
	          {{ userStore.getUserNameById(info.creator) }} {{ dayjs(info.createTime).format('YYYY-MM-DD HH:mm:ss') }}
	        </wd-divider>
			<view class="file-container">
				<template v-for="(file, index) in info.fileUrl" :key="index">
          		  <file-preview :file="file" />
          		</template>
			</view>
	      </template>
	    </wd-collapse-item>
        <!-- 一见 -->
      	<wd-collapse-item
	     
	      key="oneSee"
	      title="一见"
	      name="oneSee"
	    >
	      <template v-for="info in transformedData.filter((item) => item.fileType === 'oneSee')" :key="info.id">
	        <wd-divider>
	          {{ userStore.getUserNameById(info.creator) }} {{ dayjs(info.createTime).format('YYYY-MM-DD HH:mm:ss') }}
	        </wd-divider>
			<view class="file-container">
				<template v-for="(file, index) in info.fileUrl" :key="index">
          		  <file-preview :file="file" />
          		</template>
			</view>
	      </template>
	    </wd-collapse-item>
        <!-- 二见 -->
      	<wd-collapse-item
	     
	      key="twoSee"
	      title="二见"
	      name="twoSee"
	    >
	      <template v-for="info in transformedData.filter((item) => item.fileType === 'twoSee')" :key="info.id">
	        <wd-divider>
	          {{ userStore.getUserNameById(info.creator) }} {{ dayjs(info.createTime).format('YYYY-MM-DD HH:mm:ss') }}
	        </wd-divider>
			<view class="file-container">
				<template v-for="(file, index) in info.fileUrl" :key="index">
          		  <file-preview :file="file" />
          		</template>
			</view>
	      </template>
	    </wd-collapse-item>
	  </wd-collapse>
	  

	
  </view>
</template>
<script setup>
import dayjs from 'dayjs';	
import { ref, computed, watch, onMounted, reactive } from 'vue';
import { onReady } from '@dcloudio/uni-app';
import {
  useDictionaryStore,
  useUserStore,
  usePermissionStore 
} from '@/store/index.js'
import { getOrderFileList } from '@/api/engineering/detail.js'
import FilePreview from '@/packageA/components/file-preview/file-preview.vue';
const props = defineProps({
  // 订单id
  orderId: {
    type: Number,
    required: true
  },
});

// 字典仓库
 const dictionaryStore = useDictionaryStore()
 // 用户仓库
 const userStore = useUserStore()
// 权限参数
const permissionStore = usePermissionStore()
const hasPermission = (permissions) => {
	console.log(permissionStore.permissions,'permissions');
	console.log(permissionStore.hasPermission(permissions),'ll');
      return permissionStore.hasPermission(permissions)
    }
// 信息列表
const transformedData = ref([]);

 
const value = ref(['measureInfo1'])
// 处理获取量房信息列表
const handleGetMeasureInfoList = () => {
  uni.showLoading({
			mask: true
		})
  const params = {
    orderId: props.orderId,
    pageSize:-1,
  };
  getOrderFileList(params)
    .then((data) => {
      if (!data) return;
      transformedData.value = data;
     
    })
    .catch((error) => {
    	uni.showToast({
    		title: error,
    		icon: 'error'
    	})
    })
    .finally(() => {
      uni.hideLoading();
    });
};

onMounted(() => {
  handleGetMeasureInfoList();
});

</script>
<style lang="scss" scoped>
  .custom-layout {
	  height: calc(100vh - 300px);
  }
  .file-container {
	display: flex;
	flex-wrap: wrap;
  	gap: 16px;
  }
</style>